<template>
  <div class="loding-body" v-loading="true"></div>
</template>

<script>
export default {
  data() {
    return {
      api: {
        getUserInfo: 'getUserInfo',
      },
    }
  },
  methods: {
    async getUserInfo() {
      let redirect = this.$route.query.redirect
      let showLoginOut = redirect != undefined ? true : false
      let result = await this.Request({
        url: this.api.getUserInfo,
        showLoading: false,
        showLoginOut: showLoginOut,
      })
      sessionStorage.clear()
      sessionStorage.setItem('userInfo', JSON.stringify(result))
      if (redirect != undefined && redirect != '') {
        redirect = decodeURIComponent(redirect)
        this.$router.push(redirect)
        return
      } else {
        let menuList = result.menuList
        if (menuList == undefined || menuList.length == 0) {
          this.$router.push('pageNoPermission')
          return
        }
        let firstChildren =
          menuList[0].children != undefined && menuList[0].children.length > 0
            ? menuList[0].children[0].menuUrl
            : menuList[0].menuUrl
        this.$router.push(firstChildren)
      }
    },
  },
  created() {
    this.getUserInfo()
  },
}
</script>
<style scoped>
.loding-body {
  text-align: center;
  line-height: 50vh;
}
</style>
